const mysql = require('mysql');
const pool = mysql.createPool({
	host: 'localhost',
	user: 'root',
	password: '',
	port: 3307,
	database: 'mydb',
	timezone: 'SYSTEM',
	multipleStatements: true,
});

const query = (sql, arr) => {
	return new Promise((resolve, reject) => {
		pool.getConnection((err, connection) => {
			if (err) throw err;
			connection.query(sql, arr, (err, res, filelds) => {
				connection.release();
				if (err) reject(err);
				resolve(res);
			});
		});
	});
};

module.exports = query;
